Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
Useful procedure attributes and methods
There are many procedure attributes you can access through the procedure’s handle. This section introduces you to a few of them.
FILE-NAME attribute
After you run a persistent procedure, you can query its
FILE-NAMEattribute to see the name of the procedure file, including any pathname it was run with. This attribute can be useful to identify a procedure so that you can run something in its handle or access other attributes.PRIVATE-DATA attribute
There is a character attribute available on every handle, including procedure handles, called
PRIVATE-DATA. It is there specifically so that you can store any value you want on the handle, to help identify the object it points to, or to store other information about the object. ThePRIVATE-DATAattribute is not used by Progress in any way; it is strictly there for your application use. You could, for example, store a category of object in thePRIVATE-DATAhandle when you run the procedure, or the value of one or more parameters that were passed in to the procedure to give it a distinctive function. Because you might run the same procedure file in numerous ways, for example with different input parameters or different settings that you establish in other ways, thePRIVATE-DATAattribute gives you the ability to identify it in any way you need to.INTERNAL-ENTRIES attribute
The
INTERNAL-ENTRIESattribute returns a comma-separated list of all the internal procedures in the procedure file, and also any user-defined functions, which you’ll learn about a little later. This can help you identify the location of a routine you need to run.GET-SIGNATURE method
Given the name of any internal procedure or function in a procedure file, you can get its signature, that is, the list of parameters it requires, using the
GET-SIGNATUREmethod on the procedure handle. This is considered a method rather than an attribute simply because it requires an input parameter, the name of the routine you want the signature for. You can also pass in a blank argument to get the signature of the external procedure itself.
GET-SIGNATUREreturns a string in this format:
The
typeis the type of entry point and its possible values are:
MAINfor the external procedure itself (when you pass in an empty string).PROCEDUREfor an internal procedure.FUNCTIONfor a user-defined function. You’ll learn about user-defined functions in Chapter 14, " Defining Functions and Building Super Procedures."The
fn-return-typeis the data type that a function returns. For an internal procedure, this element of the signature is blank.Following the second comma is a list of the parameter descriptions. Each description is a space-delimited list of three elements:
As an example, here is a very simple procedure file that contains an internal procedure and a user-defined function:
The
h-testsig.pprocedure takes anINPUTparameter, theTestProcinternal procedure uses anOUTPUTparameter, and theTestFuncfunction takes anINPUTparameter and returns the data typeINTEGER.Here’s another procedure that uses
GET-SIGNATUREto get the signatures of all these routines:
This procedure executes as follows:
h-mainsig.prunsh-testsig.ppersistent and saves off its procedure handle.h-mainsig.pgets theINTERNAL-ENTRIESattribute of the procedure, which should have the valueTestProp,TestFunc.- It begins to build up a character string to display later with a
MESSAGEstatement. The first entry in the message string isTHIS-PROCEDURE:FILE-NAME. Because the built-in handle functionTHIS-PROCEDUREevaluates to the handle of the currently running procedure, this should return its filename,h-mainsig.p. Passing the empty string toGET-SIGNATUREreturns the signature of the external procedure itself.- The code loops through all the entries in the
INTERNAL-ENTRIESattribute, and for each once, saves off its name and signature.- To simulate a series of
SKIPkeywords that you could put into aMESSAGEstatement, the code adds a new line character after the signature of each entry. TheCHR(n)Progress built-in function takes anINTEGERvalue that represents the ASCII character code of any character, whether printable or not, and returns that ASCII character. In this case, 10 represents the new line character.Figure 13–8 shows the message you see when you load
h-mainsig.pinto an editor window and run it.Figure 13–8: Message box for h-mainsig.p
![]()
Interesting. The value of
THIS-PROCEDURE:FILE-NAMEisn’t what you expect. Instead you see what looks like a temporary filename. And that’s exactly what it is. When you run a procedure from the Procedure Editor or from the AppBuilder just by loading it or typing code into the editor and then clicking the Run button or pressing F2, the tool doesn’t actually run the saved procedure. In fact, you might not yet have saved the procedure file at all, or you might have changed it since you saved it. What you run is the code that is currently in the editor window or the AppBuilder’s Section Editor, depending on which tool you’re using. The tool gives this code a temporary filename, saves it off into that file, and runs it from there. That’s why you see this filename in the message box.
![]()
To see the filename you expected, rather than loading
h-mainsig.pinto an editor window and running it from there:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |